import { Component } from "solid-js";
import style from "../App.module.scss";

interface ActionButtonsProps {
  running: boolean;
  mode: "countup" | "countdown" | "current" | "alarm";
  countdownTime: number;
  targetTime: number;
  now: number;
  start: () => void;
  pause: () => void;
  reset: () => void;
  shouldDisableReset: () => boolean;
}

const ActionButtons: Component<ActionButtonsProps> = (props) => {
  return (
    <div class={style.action}>
      <input
        type="button"
        value="开始"
        onClick={props.start}
        disabled={props.running || (props.mode === "countdown" && props.countdownTime <= 0) || (props.mode === "alarm" && (props.targetTime === 0 || props.targetTime <= Math.floor(props.now / 1000)))}
      />
      <input type="button" value="暂停" onClick={props.pause} disabled={!props.running} />
      <input type="button" value="重置" onClick={props.reset} disabled={props.shouldDisableReset()} />
    </div>
  );
};

export default ActionButtons;


